 <template>
 	<view style="padding: 20rpx;">
 		<view class="box" style="padding: 40rpx 20rpx;">
 			<uni-forms :modelValue="user" :rules="rules" ref="formRef" label-width="140rpx" label-align="right">
 				<uni-forms-item label="原始密码" name="password" required>
 					<uni-easyinput type="password" v-model="user.password" placeholder="原始密码" />
 				</uni-forms-item>
 				<uni-forms-item label="新密码" name="newPassword" required>
 					<uni-easyinput type="newPassword" v-model="user.newPassword" placeholder="新密码" />
 				</uni-forms-item>
 				<uni-forms-item label="确认密码" name="confirmPassword" required>
 					<uni-easyinput type="confirmPassword" v-model="user.confirmPassword" placeholder="确认密码" />
 				</uni-forms-item>
 				<view>
 					<button type="primary" @click="save" class="my-button-primary">确认修改</button>
 				</view>
 			</uni-forms>
 		</view>
 	</view>
 </template>

 <script>
 	export default {
 		data() {
 			return {
 				user: uni.getStorageSync('xm-user'),
 				rules: {
 					password: {
 						rules: [{
 							required: true,
 							errorMessage: '请输入原始密码',
 						}]
 					},
 					newPassword: {
 						rules: [{
 							required: true,
 							errorMessage: '请输入新密码',
 						}]
 					},
 					confirmPassword: {
 						rules: [{
 							required: true,
 							errorMessage: '请确认密码',
 						}]
 					},
 				},

 			}
 		},
 		methods: {
 			save() {
 				this.$refs.formRef.validate((valid) => {
 					if (valid) {
 						this.$request.put('/updatePassword', this.user).then(res => {
 							if (res.code === '200') {
 								uni.showToast({
 									icon: 'success',
 									title: '修改密码成功'
 								})
 								this.$router.push('/pages/login/login') // 根据你的路由配置修改路径
 							} else {
 								this.$message.error(res.msg)
 							}
 						})
 					}
 				})
 			}
 		}
 	}
 </script>

 <style>
 	/* 在这里添加 my-button-primary 的样式 */
 	.my-button-primary {
 		/* 样式定义 */
 	}
 </style>